﻿using MediaBrowserSL.RIA.Services;
using MediaBrowserSL.RIA.ViewModels;
using Microsoft.Practices.Unity;

namespace MediaBrowserSL.RIA
{
    /// <summary>
    /// Locator View Model and Services
    /// </summary>
    public class Locator
    {
        private IUnityContainer container;

        public Locator()
        {
            container = new UnityContainer();

            container.RegisterType<IMediaRiaServices, MediaRiaServices>();
            container.RegisterType<IAuthenticationRiaServices, AuthenticationRiaServices>();

            container.RegisterType<MainViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<PageHomeViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<PageMoviesViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<PagePicturesViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<PageBooksViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<PageMusicViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<AuthenticationViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<ManageMoviesViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<PlayerMoviesViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<ManageAlbumsViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<ManageBooksViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<SettingsViewModel>(new ContainerControlledLifetimeManager());
        }

        #region ViewModels

        public MainViewModel Main
        {
            get
            {
                return container.Resolve<MainViewModel>();
            }
        }

        public PageHomeViewModel Home
        {
            get
            {
                return container.Resolve<PageHomeViewModel>();
            }
        }

        public PageMoviesViewModel Movies
        {
            get
            {
                return container.Resolve<PageMoviesViewModel>();
            }
        }

        public PagePicturesViewModel Pictures
        {
            get
            {
                return container.Resolve<PagePicturesViewModel>();
            }
        }

        public PageBooksViewModel Books
        {
            get
            {
                return container.Resolve<PageBooksViewModel>();
            }
        }

        public PageMusicViewModel Musics
        {
            get
            {
                return container.Resolve<PageMusicViewModel>();
            }
        }

        public AuthenticationViewModel Authentication
        {
            get
            {
                return container.Resolve<AuthenticationViewModel>();
            }
        }

        public ManageMoviesViewModel ManageMovies
        {
            get
            {
                return container.Resolve<ManageMoviesViewModel>();
            }
        }

        public PlayerMoviesViewModel PlayerMovies
        {
            get
            {
                return container.Resolve<PlayerMoviesViewModel>();
            }
        }

        public ManageAlbumsViewModel ManageAlbums
        {
            get
            {
                return container.Resolve<ManageAlbumsViewModel>();
            }
        }

        public ManageBooksViewModel ManageBooks
        {
            get
            {
                return container.Resolve<ManageBooksViewModel>();
            }
        }

        public SettingsViewModel Settings
        {
            get
            {
                return container.Resolve<SettingsViewModel>();
            }
        }

        #endregion
    }
}
